package com.situ.springboot.juc;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class CallableDemo {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        MyCallable myCallable = new MyCallable();
        // FutureTask适配类，和Thread类建立关联
        FutureTask futureTask = new FutureTask(myCallable);
        new Thread(futureTask, "CallableDemo").start();
        String str  = (String) futureTask.get();
        System.out.println(str);
    }
}

class MyCallable implements Callable{

    @Override
    public Object call() throws Exception {
        return "abc";
    }
}
